﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace chessLogic
{
    public class Game
    {
        public string Event { get; set; }
        public string Site { get; set; }
        public string Date { get; set; }
        public string Round { get; set; }
        public string White { get; set; }
        public string Black { get; set; }
        public string Result { get; set; }
        public string ECO { get; set; }
        private List<string> moves;
        private int moveNumber;

        public int MoveNumber
        {
            get { return this.moveNumber; }
            set { this.moveNumber = value; }
        }
        public List<string> Moves
        {
            get { return this.moves; }
            set { this.moves = value; }
        }

        public Game()
        {
            moves = new List<string>();
            moveNumber = 0;
        }

        public void setTags(Dictionary<string,string> tags)
        {
            this.Event = tags["Event"];
            this.Site = tags["Site"];
            this.Date = tags["Date"];
            this.Round = tags["Round"];
            this.White = tags["White"];
            this.Black = tags["Black"];
            this.Result = tags["Result"];
            this.ECO = tags["ECO"];
        }
        public string NextMove()
        {
            return moves[moveNumber++];
        }
        public bool IsFinished()
        {
            return moveNumber >= moves.Count;
        }
        public string getWinner()
        {
            Result = Result.Trim();
            if (Result.Equals("1-0"))
                return "White Won!";
            if (Result.Equals("0-1"))
                return "Black Won!";
            if (Result.Equals("*"))
                return "Set aside!";
            return "Draw Game!";
        }
        public FigureColor getWhoMove()
        {
            if (moveNumber % 2 == 0)
                return FigureColor.White;
            return FigureColor.Black;
        }
    }
}
